/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JFrameMovimento01.java
 *
 * Created on 03/04/2012, 23:30:40
 */
package br.com.nds.games.shotnup.engine;

import java.awt.event.KeyEvent;
import java.util.Locale;

/**
 *
 * @author Leonardo
 */
public class JFrameMovimento01 extends javax.swing.JFrame {

    private ThreadFrameMovimento01 threadEngine = new ThreadFrameMovimento01(this); 
    
    /** Creates new form JFrameMovimento01 */
    public JFrameMovimento01() {
        initComponents();
        this.threadEngine.start();
    }
    
    public void setJPanel1Position(int x, int y) {
        this.jPanel1.setLocation(x, y);
    }
    
    public void setJPanel2Position(int x, int y) {
        this.jPanel2.setLocation(x, y);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                formKeyPressed(evt);
            }
            public void keyReleased(java.awt.event.KeyEvent evt) {
                formKeyReleased(evt);
            }
        });
        getContentPane().setLayout(null);

        jPanel1.setBackground(new java.awt.Color(0, 0, 204));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 60, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 100, Short.MAX_VALUE)
        );

        getContentPane().add(jPanel1);
        jPanel1.setBounds(260, 320, 60, 100);

        jPanel2.setBackground(new java.awt.Color(204, 0, 51));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 160, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 60, Short.MAX_VALUE)
        );

        getContentPane().add(jPanel2);
        jPanel2.setBounds(200, 20, 160, 60);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void formKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyPressed
        if (evt.getKeyCode() == KeyEvent.VK_DOWN)
            this.threadEngine.setDown(true);
        if (evt.getKeyCode() == KeyEvent.VK_UP)
            this.threadEngine.setUp(true);
        if (evt.getKeyCode() == KeyEvent.VK_LEFT)
            this.threadEngine.setLeft(true);
        if (evt.getKeyCode() == KeyEvent.VK_RIGHT)
            this.threadEngine.setRight(true);
    }//GEN-LAST:event_formKeyPressed

    private void formKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_formKeyReleased
        if (evt.getKeyCode() == KeyEvent.VK_DOWN)
            this.threadEngine.setDown(false);
        if (evt.getKeyCode() == KeyEvent.VK_UP)
            this.threadEngine.setUp(false);
        if (evt.getKeyCode() == KeyEvent.VK_LEFT)
            this.threadEngine.setLeft(false);
        if (evt.getKeyCode() == KeyEvent.VK_RIGHT)
            this.threadEngine.setRight(false);
    }//GEN-LAST:event_formKeyReleased

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new JFrameMovimento01().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    // End of variables declaration//GEN-END:variables
}
